home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / LINAXON / LINTANHA.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.4 KB  |  51 lines

  1. // Dynamic link library implementation of NeuroSolutions LinearTanhAxon component 
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /************************************************/
  6. /* Macro to access the PE layer in matrix form */
  7.  
  8. #define data(i,j)        data[j+i*cols]
  9.  
  10. /***********************************/
  11. /* Forward activation of component */
  12.  
  13. __declspec(dllexport) void performLinearAxon(
  14.     DLLData *instance,    // Pointer to instance data (may be NULL)
  15.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  16.     int     rows,        // Number of rows of PEs in the layer
  17.     int     cols,        // Number of columns of PEs in the layer
  18.     NSFloat    *bias,        // Pointer to the layer's bias vector, one for each PE
  19.     NSFloat    beta        // Slope gain scalar, same for all PEs
  20.     )
  21. {
  22.     int i, length=rows*cols;
  23.  
  24.     for (i=0; i<length; i++) {
  25.         data[i] = beta*data[i] + bias[i];
  26.         if (data[i] < -1.0f)
  27.             data[i] = -1.0f;
  28.         else
  29.             if (data[i] > 1.0f) 
  30.                 data[i] = 1.0f;
  31.     } 
  32. }
  33.  
  34. /******************************************/
  35. /* Management of instance data (OPTIONAL) */
  36. /*
  37. __declspec(dllexport) DLLData *allocLinearAxon(
  38.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  39.     int     rows,        // Number of rows of PEs in the layer
  40.     int     cols        // Number of columns of PEs in the layer
  41.     )
  42. {
  43.     DLLData *instance = allocDLLInstance(oldInstance);
  44.     return instance;
  45. }
  46.  
  47. __declspec(dllexport) void freeLinearAxon(DLLData *instance)
  48. {
  49.     freeDLLInstance(instance);
  50. }
  51. */